package com.uwlaser.socket.client;

import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class PrintHandler extends SimpleChannelInboundHandler<String> {
		@Override
		protected void channelRead0(ChannelHandlerContext channelHandlerContext, String o) throws Exception {
			Channel channel = channelHandlerContext.channel();
			String key = BaseNettyMVBoxClient.getId(channel);
			if(SocketResultMap.containsKey(key)){
				SocketResultMap.setValue(key, o);
			} else {
				System.out.println("客户端没有发起请求，服务端发来数据："+ o);
			}
		}

		@Override
		public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
			ctx.close();
		}
}